package kandl.automation.spring.config;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.ComponentScan;
import org.springframework.context.annotation.Configuration;
import org.springframework.context.annotation.Scope;
import org.springframework.scheduling.annotation.EnableAsync;

import java.util.List;

import kandl.automation.junit.AutomationRunner;
import kandl.automation.junit.ProfileRunner;
import kandl.automation.steprunner.StepRunner;
import kandl.automation.steprunner.selenium.Command;
import kandl.automation.steprunner.selenium.SeleniumStepRunner;
import kandl.automation.steprunner.selenium.WebDriverFactory;
import kandl.automation.testsuite.TestSuiteFactory;
import kandl.automation.testsuite.excel.ExcelTestSuiteFactory;

@Configuration
@ComponentScan(basePackages = {"kandl.automation.steprunner.selenium.commands"})
@EnableAsync
public class AppConfig {

    @Bean
    @Scope("prototype")
    public ProfileRunner profileRunner() {
        return new ProfileRunner();
    }
    
    @Bean
    @Scope("prototype")
    public AutomationRunner automationRunner() {
        return new AutomationRunner();
    }
    
    @Bean
    public TestSuiteFactory sourceFactory() {
        return new ExcelTestSuiteFactory();
    }

    @Autowired
    @Bean
    public StepRunner stepRunner(WebDriverFactory webDriverFactory, List<Command> commands) {
        return new SeleniumStepRunner(webDriverFactory, commands);
    }
}
